<template>
  <article class="page">
    <headerbar>我的活动</headerbar>

    <section class="frame-content bg-light-gray list-news-img bg-white">

      <cube-scroll
        ref="scroll"
        :options="options"
        @pulling-up="onPullingUp"
      >
        <div class="item" @click="goDetail(item)" v-for="(item,index) in list" :key="index">
          <div class="img">
            <img v-if="!item.listPic" src="../../../../static/images/user_bg.jpg" alt="">
            <img v-if="item.listPic" :src="tools.getImgUrl(item.listPic)" alt="">
          </div>
          <div class="cont">
            <h2 class="title">{{item.title}}</h2>
            <div class="tip">
              <span>{{item.source}}</span>
              <span>{{tools.formatDate(item.createTime)}}</span>
            </div>
          </div>
        </div>

        <!--<div class="item" v-for="item in 10">
          <div class="img">
            <img src="../../../../static/images/user_bg.jpg" alt="">
          </div>
          <div class="cont">
            <h2 class="title">人事动态人事动态人事动态人事动态人事动态人事动态</h2>
            <div class="tip">
              <span>人民网</span>
              <span>2052-5-4</span>
            </div>
          </div>
        </div>-->
      </cube-scroll>

    </section>
    <footerbar></footerbar>
  </article>
</template>


<script>
  import footerbar from '@/components/layout/footerbar.vue'
  export default {
    components: {footerbar},
    name: 'myActivities',
    data () {
      return {
        list: [],
        files: [],
        attachmentList: [],
        channelId: '8880',
        currentIndex: 1,
        pageIndex: 1,
        pageSize: 10,
        isLoading: false,
        detail: {},
        options: {
          pullUpLoad: true,
          scrollbar: false
        },
        title: ''
      }
    },
    created () {
      this.fetchList()
    },
    methods: {
      goDetail (item) {
        this.$store.state.specialDetail = item
        if (item.title === '致敬“最美逆行者”') {
          return this.$router.push({name: 'specialDetail2020', query: {id: item.id, flag: 2}})
        }
        this.$router.push({name: 'specialDetail', query: {id: item.id, flag: 2}})
      },
      fetchList (id) {
        this.isLoading = true
        id = id || this.channelId
        let data = {
          "channelId": id || "",
          "pageNo": this.pageIndex,
          "pageSize": this.pageSize
        }
        return this.fetchService.contentPage(data).then(res => {
          if (res.code !== 0) {
            return this.tools.alert(res.message || res.resp_msg || '接口出错，请联系管理员')
          }
          this.isLoading = false
          this.pageIndex++
          this.list = this.list.concat(res.data.page)
          if (res.data.page.length === 0) {
            this.tools.tip('暂无更多')
          }
          return res
        })
      },
      hasList () {
        return this.list.length > 0 || this.topList.length > 0
      },
      /*测试栏目*/
      fetchClass () {
        let data = {
          "beyond": "",
          "channelName": "",
//          "channelType": "1",
          "createTime": "",
          "createUser": "",
          "delFlag": "",
          "description": "",
          "parentId": this.channelId,
          "id": "",
          "isCommont": "",
          "pic": "",
          "publicWay": "1",
          "tenantId": "",
          "treePath": "",
          "updateTime": "",
          "updateUser": ""
        }
        this.fetchService.childChannels(data).then(res => {
        })
      },
      onPullingUp () {
        this.fetchList().then(res => {
          setTimeout(() => {
            this.$refs.scroll.forceUpdate && this.$refs.scroll.forceUpdate(true, false)
            this.options.isPullUpLoad = false
          }, 100)
        })
      }
    }
  }
</script>

<style scoped>

</style>
